473,467 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

dynamic menu problem with onchange event

7 New Member
Hi, I am trying to make a dynamic menu using javascript and an xml file. The structure of the page (test.html) is in the code below. When I load up the page the drop-down list is there, so I select a value from the list and it passes that value to the function to get the appropriate data and it prints out the values (which it does just fine).

The thing is when I select an item from the drop-down list the other html disappears (even the doctype, and drop down list), and it just displays the values... This is all happening on the same page (test.html), so I'm not sure what is going on. Would using "document.write" in the script mess it up so it only display the output from the function? Any help is appreciated, thanks.

Expand|Select|Wrap|Line Numbers
  1. <doctype etc...>
  2. <html>
  3. <head>
  4. <script type="text/javascript">
  5. function initMenu(value) {
  6. .. code to parse xml file and print out values
  7. }
  8. </script>
  9. </head>
  10. <body>
  11. <form name="myForm">
  12. <select name="mySelect" onchange="initMenu(this.value)">
  13. <option value="Item1">Item 1</option>
  14. <option value="Item2">Item 2</option>
  15. <option value="Item3">Item 3</option>
  16. <option value="Item4">Item 4</option>
  17. </select>
  18. </form>
  19. </body>
  20. </html>
  21.  
May 22 '07 #1
2 2886
pbmods
5,821 Recognized Expert Expert
Heya, chobo. Welcome to TSDN!

Would using "document.write" in the script mess it up so it only display the output from the function?
When you use document.write, the script has to open the document for writing. If it is still loading, this isn't a problem b/c the document is still open.

On the other hand, once the document finishes loading, it is 'closed', and the only way to open it is to erase it and start over.

This would be why you're only seeing the output of your function.

What you'll want to do instead is to dynamically create a new element and insert it into the body of your document, or else alter the innerHTML property of a container element.
May 23 '07 #2
chobo
7 New Member
Thanks for the help and information! I got it to work by cocantenating the output to a variable and using the innerHTML property.
May 24 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function...
3
by: daveland | last post by:
I am working on some JavaScript that dynamically adds rows to a table in response to a button click. A new row does appear on the screen when the button is clicked. However, that table to which a...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
1
by: Steve | last post by:
hi all any body has any idea on how to fire onchange event of a pulldown menu with script. i need to trigger it so it when i select a certain option from script,the event handler is executed
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
0
by: Slickuser | last post by:
From my PHP page: Grab all data from the database. Go through a loop to generate the HTML. Client side: From the Color drop menu list, if a user change the value. It will grab that value &...
0
by: Slickuser | last post by:
From my PHP page: Grab all data from the database. Go through a loop to generate the HTML. Client side: From the Color drop menu list, if a user change the value. It will grab that value &...
1
by: jmartmem | last post by:
Greetings, I have a nagging problem with client-side dynamic dependent list boxes that perhaps someone can help me troubleshoot. I have a form with a series of dynamic dependent list boxes....
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.